package algotithm.jianzhioffer.test15;

/**
 * @author zhouyanxiang
 * @Date 2020-12-2020/12/16-14:27
 */
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int res = solution.hammingWeight(00000000000000000000000010000000);
        System.out.println(res);
    }

    public int hammingWeight(int n) {
        int mask = 1;
        int res = 0;
        for (int i = 0; i < 32; i++) {
            if ((n & mask) != 0) {
                res++;
            }
            mask <<= 1;
        }
        return res;
    }

}
